const cheerio = require("cheerio");
const fs = require('fs');

async function start() {
    const domain = 'https://www.dygod.net';
    let html = await fs.promises.readFile('test.html');
    let $ = cheerio.load(html, { decodeEntities: false });
    let total = $(".co_content8 a.ulink").length;
    let all_address = [];
    $(".co_content8 a.ulink").each(function (i, e) {
        let address = domain + $(e).attr('href');
        all_address.push(address);
    });

    console.log(all_address);


    let html2 = await fs.promises.readFile('test2.html');
    let $$ = cheerio.load(html2, { decodeEntities: false });
    let download_title = $$('div.title_all h1').text();
    let download_url = $$('a[href^="magnet:"]').eq(0).attr('href');

    console.log(download_title, download_url);

    process.exit();
}


start();